USE [Capstone]
GO

/****** Object:  StoredProcedure [dbo].[SaveCalendarDetails]    Script Date: 07/22/2012 22:44:18 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

-- =============================================
-- Author:		<Author,,Name>
-- Create date: <Create Date,,>
-- Description:	<Description,,>
-- =============================================
CREATE PROCEDURE [dbo].[SaveCalendarDetails] 
	-- Add the parameters for the stored procedure here
	@calID int = NULL,
	@Date datetime 
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

	Declare @Count int	
	Select @Count = Count(*) from CalendarDetails where calID=@calID and
		Date=@Date

	if (@Count > 0)
	Begin
		Delete From CalendarDetails where calID=@calID
	End

	Insert into CalendarDetails
		(calID, Date)
	values
		(@calID, @Date)
END

GO

